package com.lkl.hystrixdemo.order.controller;

import com.lkl.hystrixdemo.order.aspect.annotation.LklLogAnnotation;
import com.lkl.hystrixdemo.order.aspect.annotation.LklRateAnnotation;
import com.lkl.hystrixdemo.order.orderHystrixCommand.OrderHystrixCommand;
import com.lkl.hystrixdemo.order.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderHystrixController {

    @Autowired
    MemberService memberService;

    @RequestMapping("/order")
    @LklRateAnnotation
    @LklLogAnnotation
    public String order () {
        System.out.println(Thread.currentThread().getName() + ", 我是 order 接口");
        String res = memberService.getMember();
        return res;
    }
    /**
     * @return
     */
    @RequestMapping("/orderDetail")
    public String orderDetail () {
        print();
        System.out.println(Thread.currentThread().getName() + ", 我是 orderDetail 接口");
        return "success";
    }

    @RequestMapping("/hystrixOrder")
    public String hystrixOrder () {
        String res = new OrderHystrixCommand(memberService).execute();
        return res;
    }

    @LklRateAnnotation
    public void print() {
        System.out.println("print");
    }
}
